<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>object</title>
		<script src="js/vue.js"> </script>
	</head>
	<body>
		<div id="app">
			<span @click='foo'>{{msg}}</span>
			<br />
			<span>年龄：{{age}}</span>
		</div>
		<div id="ap2">
		</div>
		<script>
			//viewmodel
			let  app  = new Vue({
				//特殊字段
				el:'#app',
				//字段
				data:{
					msg:'message',
					age : 20,
					students: []
				},
				//方法
				methods:{
					foo : function(){
						alert('foo')
					},
					showMsg:function(){
						alert(this.msg)
					}
				},
				//生命周期
				created:function(){
					//用来初始化数据,一般是后台数据
					// 不能访问元素对象的
					console.log('created')
				},
				mounted:function(){
					//完成view的元素挂接
					console.log('mounted')
				}
			})
		</script>
	</body>
</html>
